from flask import Flask, request, Response
import json

app = Flask(__name__)

"""
interface接口返回xml格式
interface2接口返回json格式
"""


@app.route('/interface/sendmessage', methods=['GET', 'POST'])
def sendMessages():
    username = request.args.get('username')
    userpwd = request.args.get('userpwd')
    mobiles = request.args.get('mobiles')
    content = request.args.get('content')
    returm_code = {
        "ID": 8888,
        "status": 0,
    }
    return Response(
        response=json.dumps(returm_code),
        mimetype="application/json",
        status=200
    )


@app.route('/interface/changepassword', methods=['GET', 'POST'])
def changePassword():
    username = request.args.get('username')
    userpwd = request.args.get('userpwd')
    newpwd = request.args.get('newpwd')


@app.route('/interface/getbalance', methods=['GET', 'POST'])
def getBalance():
    username = request.args.get('username')
    userpwd = request.args.get('userpwd')

    balance = {
        "balance": 88888,
        "status": 0
    }
    return Response(
        response=json.dumps(balance),
        mimetype="application/json",
        status=200
    )


@app.route('/interface/getbalance', methods=['GET', 'POST'])
def getBalance():
    username = request.args.get('username')
    userpwd = request.args.get('userpwd')

    balance = {
        "balance": 88888
    }
    return Response(
        response=json.dumps(balance),
        mimetype="application/json",
        status=200
    )


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8888, debug=True)
